package ais.dcproject.dao.impl;

import org.hibernate.Query;
import org.hibernate.SessionFactory;

import ais.dcproject.dao.LoginDao;
import ais.dcproject.model.User;

public class LoginDaoImpl implements LoginDao {
	
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public User findUserByLoginInfo(String stuNum, String idCard) {
		Query query = sessionFactory.getCurrentSession().createQuery("from User where stuNum = ? and idCard = ?");
		query.setString(0, stuNum);
		query.setString(1, idCard);
		
		return (User) query.uniqueResult();
	}

}
